package com.bite.blog.service;

import com.bite.blog.mapper.BlogMapper;
import com.bite.blog.model.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogMapper blogMapper;

    public List<Blog> getList() {
        return blogMapper.queryAllList();
    }

    public Blog getBlogDetail(Integer id) {
        return blogMapper.queryById(id);
    }

    public Integer insertBlog(Blog blog) {
        return blogMapper.insertBlog(blog);
    }

    public Integer update(Blog blog) {
        return blogMapper.updateBlog(blog);
    }

    public Integer delete(Integer blogId) {
        Blog blog = new Blog();
        blog.setId(blogId);
        blog.setDeleteFlag(1);
        return blogMapper.updateBlog(blog);
    }
}
